/**声音流:对载入到WingSound内的音乐文件进行处理
 * 每一个声音文件对应一个声音流
 * data 2011 5 10
 * author @zzy
 */
package cn.edu.dlut.WingGame.Sound;

public class SoundStream {
	private float volume;
	private int id;
	private boolean paused;
	private boolean continuous;
	private float rate;

	public SoundStream(int id, boolean continuous, float volume) {
		this.id = id;
		this.continuous = continuous;
		this.volume = volume;
		rate = 1;
	}

	public boolean isPaused() {
		return paused;
	}

	public int getID() { // 获取当前流的id
		return id;
	}

	public void pause() {
		paused = true;
		WingSound.soundPlay.getSoundPool().pause(id);
	}

	public void resume() {
		paused = false;
		WingSound.soundPlay.getSoundPool().resume(id);
	}

	public void stop() {
		WingSound.soundPlay.getSoundPool().stop(id);
	}

	public void setContinuous(boolean continuous) { // 设置无限循环
		if (continuous)
			WingSound.soundPlay.getSoundPool().setLoop(id, -1);
		else
			WingSound.soundPlay.getSoundPool().setLoop(id, 0);

		this.continuous = continuous;
	}

	public boolean getContinuous() {
		return continuous;
	}

	public void setVolume(float volume) { // 音量大小从0.0-1.0
		this.volume = volume;
		WingSound.soundPlay.getSoundPool().setVolume(id, volume, volume);
	}

	public float getVolume() {
		return volume;
	}

	public void setRate(float rate) { // 播放速率大小从0.5-2
		this.rate = rate;
		WingSound.soundPlay.getSoundPool().setRate(id, rate);
	}

	public float getRate() {
		return rate;
	}

}
